package ch.fhnw.apsi.services;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import javax.servlet.http.HttpServletRequest;

public class ServiceHelper {
  // Parameters use String[] for the values but I just want a String.
  static Map<String, String> getParameterMap(final HttpServletRequest request) {
    final Map<String, String[]> map = request.getParameterMap();
    final Map<String, String> map2 = new HashMap<>();
    for (final Entry<String, String[]> e : map.entrySet())
      map2.put(e.getKey(), e.getValue() == null ? null : e.getValue()[0]);
    return map2;
  }
}
